<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'CategoryList.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link type="text/css" rel="stylesheet"
	href="/EasyBuy/statics/css/style.css" />

<script type="text/javascript"
	src="/EasyBuy/statics/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/EasyBuy/statics/js/menu.js"></script>

<script type="text/javascript" src="/EasyBuy/statics/js/lrscroll_1.js"></script>


<script type="text/javascript" src="/EasyBuy/statics/js/n_nav.js"></script>

</head>
<script type="text/javascript"
	src="/EasyBuy/statics/js/jquery-1.4.2.min.js"></script>

<body>
	<c:if test="${list1==null }">
		<%
			System.out.print("1");
			request.getRequestDispatcher(
						"/IndexServlet?opr=type&hre=VagueList").forward(request, response);
		%>
	</c:if>
	<!-- 头部 -->

	<%@ include file="../../common/header.jsp"%>
	<%@ include file="../../common/preHeader.jsp"%>
	<!--Begin Header Begin-->


	<!--End Menu End-->
	<div class="zhongContent">
	<div class="i_bg">
		<div class="postion">
			<span class="fl">全部 > 美妆个护 > 香水 > </span> <span class="n_ch">
				<span class="fl">品牌：<font>香奈儿</font> </span> <a href="#"><img
					src="/EasyBuy/statics/images/s_close.gif" /> </a> </span>
		</div>
		<!--End 筛选条件 End-->

		<div class="content mar_20">
			<!-- 引入浏览历史页面 -->
			<%@ include file="../../common/CategorySide.jsp"%>
			
			<div class="l_list">
				<div class="list_t">
					<span class="fl list_or"> <a>默认</a> <a>
							<span class="fl">销量</span> <span class="i_up" id="xiaoShang">销量从低到高显示</span> <span
							class="i_down" id="xiaoXia">销量从高到低显示</span> </a> <a> <span class="fl">价格</span>
							<span class="i_up" id="sheng">价格从低到高显示</span> <span
							class="i_down" id="jiang">价格从高到低显示</span> </a> <a id="xin">新品</a> </span> <span
						class="fr" id="jiJian"></span>
				</div>
				<div class="list_c">

					<ul class="cate_list">
					</ul>

					<div class="pages">
						
					</div>



				</div>
			</div>
		</div>
		</div>
		<input type="hidden" value="<%=request.getParameter("name")%>" id="yinName"/>
		<%@ include file="../../common/footer.jsp"%>

		<!-- 脚部 -->
	</div>
</body>
<script type="text/javascript">
	$(document).ready(function() {
		function hideType() {
			$(".leftNav").hide();
		}
		hideType();
		selectAll();
		//选择商品分页
  		function selectAll(currPageNotransmit){	
  			$(".s_ipt").attr("value",$("#yinName").val());
  			var name=$("#yinName").val();
  			var ur;
  			if(currPageNotransmit==""||currPageNotransmit==null||currPageNotransmit.length==0){
  				ur="opr=sousuoLists"+"&name="+name;
  			}else{
  				ur="opr=sousuoLists&pageIndex="+currPageNotransmit+"&name="+name;
  			}
  			$.getJSON("IndexServlet",ur,callBackSou);
  			}
			function callBackSou(dataSou){
				$(".cate_list").html("");
				$(".pages").html("");
				if(dataSou.productServiceList.length>0){
					for(var i=0;i<dataSou.productServiceList.length;i++){
							$(".cate_list").append("<li>"
								+ "<div class='img'>"
								+ "<a href='ConmmodityDetailsServlet?opr=productDetils&id="
								+ dataSou.productServiceList[i].id
								+ "'><img src='/EasyBuy/statics/images/"+dataSou.productServiceList[i].fileName+"' "+
								"width='210' height='185' />"
								+ "</a>"
								+ "</div>"
								+ "<div class='price'>"
								+ "<font>￥<span>"
								+ dataSou.productServiceList[i].price
								+ "</span>"
								+ "</font>&nbsp;"
								+ dataSou.productServiceList[i].integral
								+ "R"
								+ "</div>"
								+ "<div class='name'>"
								+ "<a href='#'>"
								+ dataSou.productServiceList[i].name
								+ "</a>"
								+ "</div>"
								+ "<div class='carbg'>"
								+ "<a class='ss' title='"+dataSou.productServiceList[i].id+"'>收藏</a> <a title='"+dataSou.productServiceList[i].id+"' class='j_car'>加入购物车</a>"
								+ "</div>"
								+ "</li>");
					}
					$(".pages").append("<a class='p_pre' id='shou'>首页</a><a class='p_pre' id='shang'>上一页</a><a class='p_pre' id='xia'>下一页</a><a class='p_pre' id='mo'>末页</a>");
					$("#shou").click(function(){//首页
  						selectAll();
  					});
  					$("#shang").click(function(){//上一页
  						selectAll(dataSou.currPageNo-1);
  					});
  					$("#xia").click(function(){//下一页
  						selectAll(dataSou.currPageNo+1);
  					});
  					$("#mo").click(function(){//最后一页
  						selectAll(dataSou.totalCount);
  					});	
  					$("#sheng").click(function(){
  						
  						selectSheng();
		function selectSheng(currPageNotransmit){	
  			var urSheng;
  			var nameSheng=$("#yinName").val();
  			if(currPageNotransmit==""||currPageNotransmit==null||currPageNotransmit.length==0){
  				urSheng="opr=categoryVagueSheng"+"&name="+nameSheng;
  			}else{
  				urSheng="opr=categoryVagueSheng&pageIndex="+currPageNotransmit+"&name="+nameSheng;
  			}
  			$.getJSON("ConmmodityListServlet",urSheng,callBackSheng);
  			}
			function callBackSheng(dataSheng){
				$(".cate_list").html("");
				$(".pages").html("");
						for ( var i = 0; i < dataSheng.productServiceList.length; i++) {
							$(".cate_list").append("<li>"
								+ "<div class='img'>"
								+ "<a href='ConmmodityDetailsServlet?opr=productDetils&id="
								+ dataSheng.productServiceList[i].id
								+ "'><img src='/EasyBuy/statics/images/"+dataSheng.productServiceList[i].fileName+"' "+
								"width='210' height='185' />"
								+ "</a>"
								+ "</div>"
								+ "<div class='price'>"
								+ "<font>￥<span>"
								+ dataSheng.productServiceList[i].price
								+ "</span>"
								+ "</font>&nbsp;"
								+ dataSheng.productServiceList[i].integral
								+ "R"
								+ "</div>"
								+ "<div class='name'>"
								+ "<a href='#'>"
								+ dataSheng.productServiceList[i].name
								+ "</a>"
								+ "</div>"
								+ "<div class='carbg'>"
								+ "<a class='ss' title='"+dataSheng.productServiceList[i].id+"'>收藏</a> <a title='"+dataSheng.productServiceList[i].id+"' class='j_car'>加入购物车</a>"
								+ "</div>"
								+ "</li>");
						}
						$(".pages").append("<a class='p_pre' id='shou'>首页</a><a class='p_pre' id='shang'>上一页</a><a class='p_pre' id='xia'>下一页</a><a class='p_pre' id='mo'>末页</a>");
					$("#shou").click(function(){//首页
  						selectSheng();
  					});
  					$("#shang").click(function(){//上一页
  						selectSheng(dataSheng.currPageNo-1);
  					});
  					$("#xia").click(function(){//下一页
  						selectSheng(dataSheng.currPageNo+1);
  					});
  					$("#mo").click(function(){//最后一页
  						selectSheng(dataSheng.totalCount);
  					});	
						shouCang();
						addCar();
			}
		});
		$("#jiang").click(function(){
  						
  						selectJiang();
		function selectJiang(currPageNotransmit){	
  			var urJiang;
  			var nameJiang=$("#yinName").val();
  			if(currPageNotransmit==""||currPageNotransmit==null||currPageNotransmit.length==0){
  				urJiang="opr=categoryVagueJiang"+"&name="+nameJiang;
  			}else{
  				urJiang="opr=categoryVagueJiang&pageIndex="+currPageNotransmit+"&name="+nameJiang;
  			}
  			$.getJSON("ConmmodityListServlet",urJiang,callBackJiang);
  			}
			function callBackJiang(dataJiang){
				
				$(".cate_list").html("");
				$(".pages").html("");
						for ( var i = 0; i < dataJiang.productServiceList.length; i++) {
							$(".cate_list").append("<li>"
								+ "<div class='img'>"
								+ "<a href='ConmmodityDetailsServlet?opr=productDetils&id="
								+ dataJiang.productServiceList[i].id
								+ "'><img src='/EasyBuy/statics/images/"+dataJiang.productServiceList[i].fileName+"' "+
								"width='210' height='185' />"
								+ "</a>"
								+ "</div>"
								+ "<div class='price'>"
								+ "<font>￥<span>"
								+ dataJiang.productServiceList[i].price
								+ "</span>"
								+ "</font>&nbsp;"
								+ dataJiang.productServiceList[i].integral
								+ "R"
								+ "</div>"
								+ "<div class='name'>"
								+ "<a href='#'>"
								+ dataJiang.productServiceList[i].name
								+ "</a>"
								+ "</div>"
								+ "<div class='carbg'>"
								+ "<a class='ss' title='"+dataJiang.productServiceList[i].id+"'>收藏</a> <a title='"+dataJiang.productServiceList[i].id+"' class='j_car'>加入购物车</a>"
								+ "</div>"
								+ "</li>");
						}
						$(".pages").append("<a class='p_pre' id='shou'>首页</a><a class='p_pre' id='shang'>上一页</a><a class='p_pre' id='xia'>下一页</a><a class='p_pre' id='mo'>末页</a>");
					$("#shou").click(function(){//首页
  						selectJiang();
  					});
  					$("#shang").click(function(){//上一页
  						selectJiang(dataJiang.currPageNo-1);
  					});
  					$("#xia").click(function(){//下一页
  						selectJiang(dataJiang.currPageNo+1);
  					});
  					$("#mo").click(function(){//最后一页
  						selectJiang(dataJiang.totalCount);
  					});	
						shouCang();
						addCar();
			}
		});
		$("#xin").click(function(){
  						
  						selectXin();
		function selectXin(currPageNotransmit){	
  			var urXin;
  			var nameXin=$("#yinName").val();
  			if(currPageNotransmit==""||currPageNotransmit==null||currPageNotransmit.length==0){
  				urXin="opr=categoryVagueXin"+"&name="+nameXin;
  			}else{
  				urXin="opr=categoryVagueXin&pageIndex="+currPageNotransmit+"&name="+nameXin;
  			}
  			$.getJSON("ConmmodityListServlet",urXin,callBackXin);
  			}
			function callBackXin(dataXin){
				$(".cate_list").html("");
				$(".pages").html("");
					for ( var i = 0; i < dataXin.productServiceList.length; i++) {
						
						$(".cate_list").append("<li>"
							+ "<div class='img'>"
							+ "<a href='ConmmodityDetailsServlet?opr=productDetils&id="
							+ dataXin.productServiceList[i].id
							+ "'><img src='/EasyBuy/statics/images/"+dataXin.productServiceList[i].fileName+"' "+
							"width='210' height='185' />"
							+ "</a>"
							+ "</div>"
							+ "<div class='price'>"
							+ "<font>￥<span>"
							+ dataXin.productServiceList[i].price
							+ "</span>"
							+ "</font>&nbsp;"
							+ dataXin.productServiceList[i].integral
							+ "R"
							+ "</div>"
							+ "<div class='name'>"
							+ "<a href='#'>"
							+ dataXin.productServiceList[i].name
							+ "</a>"
							+ "</div>"
							+ "<div class='carbg'>"
							+ "<a class='ss' title='"+dataXin.productServiceList[i].id+"'>收藏</a> <a title='"+dataXin.productServiceList[i].id+"' class='j_car'>加入购物车</a>"
							+ "</div>"
							+ "</li>");
						}
						$(".pages").append("<a class='p_pre' id='shou'>首页</a><a class='p_pre' id='shang'>上一页</a><a class='p_pre' id='xia'>下一页</a><a class='p_pre' id='mo'>末页</a>");
					$("#shou").click(function(){//首页
  						selectXin();
  					});
  					$("#shang").click(function(){//上一页
  						selectXin(dataXin.currPageNo-1);
  					});
  					$("#xia").click(function(){//下一页
  						selectXin(dataXin.currPageNo+1);
  					});
  					$("#mo").click(function(){//最后一页
  						selectXin(dataXin.totalCount);
  					});	
						shouCang();
						addCar();
			}
		});
		$("#xiaoShang").click(function(){
  						
  						selectXiaoShang();
		function selectXiaoShang(currPageNotransmit){	
  			var urXiaoShang;
  			var nameXiaoShang=$("#yinName").val();
  			if(currPageNotransmit==""||currPageNotransmit==null||currPageNotransmit.length==0){
  				urXiaoShang="opr=categoryVagueXiaoShang"+"&name="+nameXiaoShang;
  			}else{
  				urXiaoShang="opr=categoryVagueXiaoShang&pageIndex="+currPageNotransmit+"&name="+nameXiaoShang;
  			}
  			$.getJSON("ConmmodityListServlet",urXiaoShang,callBackXiaoShang);
  			}
			function callBackXiaoShang(dataXiaoShang){
				$(".cate_list").html("");
				$(".pages").html("");
						for ( var i = 0; i < dataXiaoShang.productServiceList.length; i++) {
							$(".cate_list").append("<li>"
								+ "<div class='img'>"
								+ "<a href='ConmmodityDetailsServlet?opr=productDetils&id="
								+ dataXiaoShang.productServiceList[i].id
								+ "'><img src='/EasyBuy/statics/images/"+dataXiaoShang.productServiceList[i].fileName+"' "+
								"width='210' height='185' />"
								+ "</a>"
								+ "</div>"
								+ "<div class='price'>"
								+ "<font>￥<span>"
								+ dataXiaoShang.productServiceList[i].price
								+ "</span>"
								+ "</font>&nbsp;"
								+ dataXiaoShang.productServiceList[i].integral
								+ "R"
								+ "</div>"
								+ "<div class='name'>"
								+ "<a href='#'>"
								+ dataXiaoShang.productServiceList[i].name
								+ "</a>"
								+ "</div>"
								+ "<div class='carbg'>"
								+ "<a class='ss' title='"+dataXiaoShang.productServiceList[i].id+"'>收藏</a> <a title='"+dataXiaoShang.productServiceList[i].id+"' class='j_car'>加入购物车</a>"
								+ "</div>"
								+ "</li>");
						}
						$(".pages").append("<a class='p_pre' id='shou'>首页</a><a class='p_pre' id='shang'>上一页</a><a class='p_pre' id='xia'>下一页</a><a class='p_pre' id='mo'>末页</a>");
					$("#shou").click(function(){//首页
  						selectXiaoShang();
  					});
  					$("#shang").click(function(){//上一页
  						selectXiaoShang(dataXiaoShang.currPageNo-1);
  					});
  					$("#xia").click(function(){//下一页
  						selectXiaoShang(dataXiaoShang.currPageNo+1);
  					});
  					$("#mo").click(function(){//最后一页
  						selectXiaoShang(dataXiaoShang.totalCount);
  					});	
						shouCang();
						addCar();
			}
		});
		$("#xiaoXia").click(function(){
  						
  						selectXiaoXia();
		function selectXiaoXia(currPageNotransmit){	
  			var urXiaoXia;
  			var nameXiaoXia=$("#yinName").val();
  			if(currPageNotransmit==""||currPageNotransmit==null||currPageNotransmit.length==0){
  				urXiaoXia="opr=categoryVagueXiaoXia"+"&name="+nameXiaoXia;
  			}else{
  				urXiaoXia="opr=categoryVagueXiaoXia&pageIndex="+currPageNotransmit+"&name="+nameXiaoXia;
  			}
  			$.getJSON("ConmmodityListServlet",urXiaoXia,callBackXiaoXia);
  			}
			function callBackXiaoXia(dataXiaoXia){
				$(".cate_list").html("");
				$(".pages").html("");
						for ( var i = 0; i < dataXiaoXia.productServiceList.length; i++) {
							$(".cate_list").append("<li>"
								+ "<div class='img'>"
								+ "<a href='ConmmodityDetailsServlet?opr=productDetils&id="
								+ dataXiaoXia.productServiceList[i].id
								+ "'><img src='/EasyBuy/statics/images/"+dataXiaoXia.productServiceList[i].fileName+"' "+
								"width='210' height='185' />"
								+ "</a>"
								+ "</div>"
								+ "<div class='price'>"
								+ "<font>￥<span>"
								+ dataXiaoXia.productServiceList[i].price
								+ "</span>"
								+ "</font>&nbsp;"
								+ dataXiaoXia.productServiceList[i].integral
								+ "R"
								+ "</div>"
								+ "<div class='name'>"
								+ "<a href='#'>"
								+ dataXiaoXia.productServiceList[i].name
								+ "</a>"
								+ "</div>"
								+ "<div class='carbg'>"
								+ "<a class='ss' title='"+dataXiaoXia.productServiceList[i].id+"'>收藏</a> <a title='"+dataXiaoXia.productServiceList[i].id+"' class='j_car'>加入购物车</a>"
								+ "</div>"
								+ "</li>");
						}
						$(".pages").append("<a class='p_pre' id='shou'>首页</a><a class='p_pre' id='shang'>上一页</a><a class='p_pre' id='xia'>下一页</a><a class='p_pre' id='mo'>末页</a>");
					$("#shou").click(function(){//首页
  						selectXiaoXia();
  					});
  					$("#shang").click(function(){//上一页
  						selectXiaoXia(dataXiaoXia.currPageNo-1);
  					});
  					$("#xia").click(function(){//下一页
  						selectXiaoXia(dataXiaoXia.currPageNo+1);
  					});
  					$("#mo").click(function(){//最后一页
  						selectXiaoXia(dataXiaoXia.totalCount);
  					});	
						shouCang();
						addCar();
			}
		});
					shouCang();
					addCar();
				}else {
					location.href="/EasyBuy/pre/Index.jsp";
				}
				
			}
		
		
							
		$(".fl list_or>a").mouseenter(function(){
			$(this).addClass("now");
		});
		shouCang();
		function shouCang(){
			$(".ss").click(function(){
			var productId=$(this).attr("title");
			var userId=$(".user").attr("title");
			$.getJSON("/EasyBuy/CollectServlet","opr=categoryShou&productId="+productId+"&userId="+userId,callBackShou);
			function callBackShou(dataShou){
				if(dataShou=="have"){
					alert("已有该收藏");
				}else if(dataShou=="success"){
					alert("收藏成功");
				}else if(dataShou=="error"){
					alert("收藏失败");
				}
			}
		});
		}
		addCar();
		//加入购物车
		function addCar(){
			$(".j_car").click(function(){
			var productId=$(this).attr("title");
			var userId=$(".user").attr("title");
			add();
			function add(){
				$.get("BuyCarServlet","opr=addBuyCar&uId="+userId+"&pId="+productId+"&pNum=1",function(data){
					if(data == "cg"){
						alert("添加成功");
					}else if(data=="sb"){
						alert("添加失败");
					}
				});
			}
		});	
		}
	});
</script>
</html>
